<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: GoldPlay.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: GoldPlay.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/**
 * @copyright: Copyright (C) 2019
 * @desc: 
 * @author: liuliguo 
 * @file: GolePlay.js
 */

import Player from './Player'
import { CONPONENTS_MAP } from './config/ComponentConfig'
import BaseComponent from './base/BaseComponent'
import ComponentsController from './components/ComponentsController'
import SideControlBar from './control-bar/SideControlBar'
import NearControlBar from './control-bar/NearControlBar'

class GoldPlay extends Player {
  // poster = ''
  // startTime = 1000
  // controlBarAutoHide = true
  // controlBarAutoHideTime = 1
  libPath = null
  /**
   * GoldPlay is the class exposed to user and inherited from Player
   * @constructs
   * @param {Elemnent} el - The container of rendering player
   * @param {Object} options - The setting of the player
   */
  constructor(el, options) {
    super(el, options)
    this.options.processURL = options.processURL
    this.libPath = options.libPath
    this.init()
  }

  /**
   * @method
   * @name getComponent
   * @param {String} name - component name
   * @description get the component registered in components map
   */
  static getComponent(name) {
    return CONPONENTS_MAP[name]
  }
  /**
   * @method
   * @name registerComponent
   * @param {String} name - component name
   * @param {Class} componentToAdd - The component class defined by user
   * @param {String} [pos=right] - Which side of control bar
   * @param {number} [index=-1] - Display index, last by default
   * @description register the new component to components map and it will be instantiated and rendered when player is inited
   */
  static registerComponent(name, componentToAdd, pos = 'right', index = -1) {
    if (typeof name !== 'string' || !name) {
      throw new Error(
        `Illegal component name, "${name}"; must be a non-empty string.`
      )
    }

    const isComp = Object.prototype.isPrototypeOf.call(BaseComponent, componentToAdd.prototype)

    if (!isComp) {
      throw new Error(
        `Illegal component, "${name}"; must be a BaseComponent subclass.`
      )
    }
    CONPONENTS_MAP[name] = componentToAdd
    ComponentsController.addComponet(name)
    if(pos === 'left') {
      NearControlBar.addCustomControl(name, index)
    } else {
      SideControlBar.addCustomControl(name, index)
    }
  }

}

export default GoldPlay
</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="GoldPlay.html">GoldPlay</a></li><li><a href="Player.html">Player</a></li></ul><h3>Events</h3><ul><li><a href="Player.html#event:end">end</a></li><li><a href="Player.html#event:pause">pause</a></li><li><a href="Player.html#event:play">play</a></li><li><a href="Player.html#event:seeking">seeking</a></li></ul><h3>Global</h3><ul><li><a href="global.html#changeRate">changeRate</a></li><li><a href="global.html#changeSpeed">changeSpeed</a></li><li><a href="global.html#changeSrc">changeSrc</a></li><li><a href="global.html#destroy">destroy</a></li><li><a href="global.html#Events">Events</a></li><li><a href="global.html#getComponent">getComponent</a></li><li><a href="global.html#pause">pause</a></li><li><a href="global.html#play">play</a></li><li><a href="global.html#registerComponent">registerComponent</a></li><li><a href="global.html#seek">seek</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.3</a> on Thu Jan 16 2020 10:40:02 GMT+0800 (GMT+08:00)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
